package com.tianze.tzkf.function.home;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyco.tablayout.SlidingTabLayout;
import com.tianze.tzkf.R;
import com.tianze.tzkf.base.BaseFragment;
import com.tianze.tzkf.function.aboutUs.AboutUsFragment;
import com.tianze.tzkf.function.hardwareInfo.HardWareFragment;
import com.tianze.tzkf.function.leadRecord.LeadRecordFragment;
import com.tianze.tzkf.function.systemLayout.SystemLayoutFragment;
import com.tianze.tzkf.view.CircleImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
 * Created by Zcyang on 2018/12/27.
 */
public class HomeFragment extends BaseFragment {


    @BindView(R.id.stl_home)
    SlidingTabLayout stlHome;
    @BindView(R.id.vp_home)
    ViewPager vpHome;

    LeadRecordFragment leadRecordFragment;
    SystemLayoutFragment systemLayoutFragment;
    HardWareFragment hardWareFragment;
    AboutUsFragment aboutUsFragment;


    private String[] menuItems = {"交易记录", "系统配置", "硬件信息", "关于我们"};

    public static HomeFragment newInstance() {

        Bundle args = new Bundle();

        HomeFragment fragment = new HomeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_home;
    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected void initData() {

        if (leadRecordFragment == null) {
            leadRecordFragment = LeadRecordFragment.newInstance();
        }
        if (systemLayoutFragment == null) {
            systemLayoutFragment = SystemLayoutFragment.newInstance();
        }
        if (hardWareFragment == null) {
            hardWareFragment = HardWareFragment.newInstance();
        }
        if (aboutUsFragment == null) {
            aboutUsFragment = AboutUsFragment.newInstance();
        }

        List<Fragment> fragmentList = new ArrayList<>();
        fragmentList.add(leadRecordFragment);
        fragmentList.add(systemLayoutFragment);
        fragmentList.add(hardWareFragment);
        fragmentList.add(aboutUsFragment);
        HomePagerAdapter homePagerAdapter = new HomePagerAdapter(getFragmentManager(),fragmentList);
        vpHome.setAdapter(homePagerAdapter);
        stlHome.setViewPager(vpHome, menuItems);

    }



}
